dynamic class com.c3d.common.net.NetLoadMarshall extends MovieClip
{
    var _loadQueueRunning: Boolean = false;
    var _loaders;
    var _pollingInterval;

    function NetLoadMarshall()
    {
        super();
        this._loaders = new Array();
    }

    function requestLoad($src, $type, $displayObjectWrapper)
    {
        var __reg2 = new Object();
        var __reg3 = Math.round(Math.random() * 10000000);
        __reg2.lUid = __reg3;
        __reg2.lSrc = $src;
        __reg2.lType = $type;
        __reg2.loaderObject = null;
        __reg2.loaderDisplayObject = $displayObjectWrapper;
        __reg2.loaderXML = new XML();
        this._loaders.push(__reg2);
        this.startupLoadQueue(this._loaders);
        return __reg3;
    }

    function startupLoadQueue($queueData)
    {
        var __reg2 = true;
        if (!this._loadQueueRunning && $queueData.length > 0) 
        {
            this._loadQueueRunning = true;
            this.startLoad();
        }
        else 
        {
            __reg2 = false;
        }
        return __reg2;
    }

    function destroyLoadQueue()
    {
    }

    function startLoad()
    {
        if (this._loaders.length > 0) 
        {
            var __reg2 = this._loaders[0];
            if ((__reg0 = this._loaders[0].lType) === "xml") 
            {
                this.startXMLLoad(this._loaders[0]);
            }
            else if (__reg0 === "json") 
            {
                this.startJSONLoad(this._loaders[0]);
            }
            else if (__reg0 === "image") 
            {
                this.startImageLoad(this._loaders[0]);
            }
            return;
        }
        this._loadQueueRunning = false;
        com.c3d.common.events.CentralDispatch.dispatchEvent({type: com.c3d.common.events.NetworkEvent.NETWORK_QUEUE_EMPTIED, target: this});
    }

    function startXMLLoad($iLoadObj)
    {
        var __reg2 = new XML();
        __reg2.ignoreWhite = true;
        __reg2.onLoad = mx.utils.Delegate.create(this, this.internal_onLoadComplete);
        __reg2.onData = mx.utils.Delegate.create(this, this.internal_onLoadData);
        __reg2.onHTTPStatus = mx.utils.Delegate.create(this, this.internal_onLoadHTTPStatus);
        com.c3d.common.events.CentralDispatch.dispatchEvent({type: com.c3d.common.events.NetworkEvent.NETWORK_REQUEST_START, target: this, loadtype: "TEXT", uid: $iLoadObj.lUid});
        __reg2.load($iLoadObj.lSrc);
        $iLoadObj.loaderObject = __reg2;
    }

    function startImageLoad($iLoadObj)
    {
        var __reg5 = new MovieClipLoader();
        if (_root.runMode == "avm2Nested") 
        {
            this._pollingInterval = setInterval(mx.utils.Delegate.create(this, this.pollLoadState), 50);
        }
        else 
        {
            var __reg3 = new Object();
            __reg3.onLoadComplete = mx.utils.Delegate.create(this, this.internal_onLoadComplete);
            __reg3.onLoadInit = mx.utils.Delegate.create(this, this.internal_onLoadInit);
            __reg3.onHTTPStatus = mx.utils.Delegate.create(this, this.internal_onLoadHTTPStatus);
            __reg3.onLoadError = mx.utils.Delegate.create(this, this.internal_onLoadError);
            __reg5.addListener(__reg3);
        }
        var __reg6 = $iLoadObj.loaderDisplayObject.createEmptyMovieClip("loadedContent", $iLoadObj.loaderDisplayObject.getNextHighestDepth());
        com.c3d.common.events.CentralDispatch.dispatchEvent({type: com.c3d.common.events.NetworkEvent.NETWORK_REQUEST_START, target: this, loadtype: "BINARY", uid: $iLoadObj.lUid});
        var __reg9 = __reg5.loadClip($iLoadObj.lSrc, $iLoadObj.loaderDisplayObject.loadedContent);
        $iLoadObj.loaderObject = __reg5;
    }

    function startJSONLoad($iLoadObj)
    {
    }

    function pollLoadState()
    {
        var __reg2 = this._loaders[0].getProgress();
        var __reg3 = __reg2.bytesLoaded / __reg2.bytesTotal;
        if (__reg3 >= 1) 
        {
            com.c3d.common.events.CentralDispatch.dispatchEvent({type: com.c3d.common.events.NetworkEvent.NETWORK_REQUEST_COMPLETE, loadtype: "BINARY", uid: this._loaders[0].lUid, target: this});
            clearInterval(this._pollingInterval);
            this.loadNext();
        }
    }

    function internal_onLoadComplete($event)
    {
    }

    function internal_onLoadInit($event)
    {
        com.c3d.common.events.CentralDispatch.dispatchEvent({type: com.c3d.common.events.NetworkEvent.NETWORK_REQUEST_COMPLETE, loadtype: "BINARY", uid: this._loaders[0].lUid, target: this});
    }

    function internal_onLoadData($event)
    {
        var __reg3 = this._loaders[0].lUid;
        var __reg2 = this.parseResponse($event);
        com.c3d.common.events.CentralDispatch.dispatchEvent({type: com.c3d.common.events.NetworkEvent.NETWORK_REQUEST_COMPLETE, target: this, loadtype: "TEXT", uid: __reg3, data: __reg2});
        this.loadNext();
    }

    function loadNext()
    {
        this._loaders.shift();
        this.startupLoadQueue(this._loaders);
    }

    function internal_onLoadHTTPStatus($event)
    {
    }

    function internal_onLoadError($event)
    {
    }

    function parseResponse($rawResponse)
    {
        var __reg2 = null;
        var __reg1 = new XML();
        __reg1.ignoreWhite = true;
        __reg1.parseXML($rawResponse);
        $rawResponse;
        if (__reg1.status == 0) 
        {
            __reg2 = net.produxion.utils.XML2Object.deserialize(__reg1);
        }
        return __reg2;
    }

}
